import request from '../utils/request'
import { UserDTO,EditPwdDTO } from '@/types/user';

export const login = (loginParam) => {
    return request({
        url: '/user/login',
        method: 'post',
        data: loginParam,
    });
}

export const userList = () => {
    return request({
        url: '/user/list',
        method: 'get',
    });
}

export const userListLikeName = (name: string) => {
    return request({
        // 链接方式：http://localhost:8085/user/list/name
        url: '/user/list/' + name,
        method: 'get',
    });
}

export const userListById = (id: number) => {
    return request({
        // 链接方式：http://localhost:8085/user/list/name
        url: '/user/list/finalByID/' + id,
        method: 'get',
    });
}


export function uploadBinaryImage(data: FormData) {
    return request({
        url: '/common/upload',
        method: 'post',
        data: data,
        // 文件上传的格式的请求头
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    })
}

export function AddUser(data: UserDTO) {
    return request({
        url: '/user/Add',
        method: 'post',
        data: data,
    })
}

export function EditUser(data: UserDTO) {
    return request({
        url: '/user/Edit',
        method: 'put',
        data: data,
    })
}

export function DeleteUser(uid: number) {
    return request({
        url: '/user/DeleteById/' + uid,
        method: 'DELETE'
    })
}


export function EditPwd(data: EditPwdDTO) {
    return request({
        url: '/user/EditPwd',
        method: 'put',
        data:data
    })
}